package com.springboot.controller;

import com.springboot.model.Menu;
import com.springboot.service.MenuService;
import org.apache.shardingsphere.api.hint.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: TongRui乀
 * @Date: 2020-02-13 9:10
 * @description：
 */
@RestController
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("getMenuById")
    public Menu getMenuById(Integer id, Integer tenantId){

        HintManager manager = HintManager.getInstance();

        manager.setDatabaseShardingValue(tenantId);

//        manager.addDatabaseShardingValue("menu", tenantId);

        return this.menuService.getMenuById(id);
    }

}
